$(document).ready(function(){
    $('input[name="phone_number"]').blur(function () {
        var phone_number = $(this).val();
        if(phone_number.length != 11){
            $("#s_0").html("号码输入错误！！！");
            return;
        }else {
            $("#s_0").html("");
        }
        $.get("/checkInfo",{phone_number:phone_number},function (data) {
            var span = $("#s_0");
            var flag = data.exsit;
            if(flag==1){
                span.css("color","red");
                span.html("该号码已经被注册");
            }else{
                span.css("color","green");
                span.html("号码可注册")
            }
        });
    });

    $('input[name="email"]').blur(function () {
        var email = $(this).val();
        $.get("/checkInfo",{email:email},function (data) {
            var span = $("#s_1");
            var flag = data.exsit;
            if(flag==1){
                span.css("color","red");
                span.html("该邮箱已经被注册");
            }else{
                span.css("color","green");
                span.html("邮箱可注册")
            }
        });
    });

    $('input[name="name"]').blur(function () {
        var name = $(this).val();
        $.get("/checkInfo",{name:name},function (data) {
            var span = $("#s_2");
            var flag = data.exsit;
            if(flag==1){
                span.css("color","red");
                span.html("该用户名太受欢迎啦！请换一个");
            }else{
                span.css("color","green");
                span.html("用户名可用")
            }
        });
    });

    $("#comfim").blur(function () {
        var pwd = $('input[name="password"]').val();
        if(pwd != $(this).val()){
            $("#s_comfim").html("两次密码输入不一致！！！");
        }else {
            $("#s_comfim").html("");
        }
    });

});